/**
 * @version $Revision: 25 $
 * @class Ext.RemoteComponent
 * @extends Ext.Panel
 * @xtype remote
 * @author Andrew Stephanoff <andrew.stephanoff@gmail.com>
 *
 * Create basic {@link Ext.Panel} with remote renderer.
 * Predefined configuration:
 * <code>
 * var cfg = {
 * 	   layout: 'fit',
 *     border: false,
 *     renderer: Ext.RemoteComponent.render, // {@link Ext.Updater.RemoteRenderer} instance
 *     autoLoad: {
 *         nocache: true,
 *         scripts: true,
 *         scope: this // {@link Ext.RemoteComponent} instance
 *     }
 * };
 * </code>
 *
 * Usage:
 * <code>
 * var cfg = {
 *     xtype: 'remote',
 *     autoLoad: {
 *         url: '/path/to/config'
 *     }
 * };
 * var cmp = Ext.create(cfg);
 * </code>
 * or
 * <code>
 * var cmp = new Ext.RemoteComponent({
 *     autoLoad: {
 *         url: '/path/to/config'
 *     }
 * });
 * </code>
 */
Ext.RemoteComponent = Ext.extend(Ext.Panel, {
    /**
     * @constructor
     * @param {Object} cfg The config object
     * @xtype remote
     */
    constructor: function(cfg) {
        Ext.applyIf(cfg, {
            layout: 'fit',
            border: false,
            renderer: Ext.RemoteComponent.renderer,
            autoLoad: {}
        });
        if ('url' in cfg) {
            cfg.autoLoad.url = cfg.url;
            delete cfg.url;
        }
        Ext.applyIf(cfg.autoLoad, {
            nocache: true,
            scripts: true,
            scope: this
        });
        if (!('title' in cfg)) {
            cfg.header = false;
        }
        if ('xtype' in cfg) {
            delete cfg.xtype;
        }
        Ext.Panel.prototype.constructor.call(this, cfg);
    }
});
Ext.RemoteComponent.renderer = new Ext.Updater.RemoteRenderer;
Ext.reg('remote', Ext.RemoteComponent);